package(default_visibility = ["//:__subpackages__"])

licenses(["notice"])

cc_library(
    name = "streaming_aead_wrapper",
    srcs = ["streaming_aead_wrapper.cc"],
    hdrs = ["streaming_aead_wrapper.h"],
    include_prefix = "tink/streamingaead",
    deps = [
        ":decrypting_input_stream",
        ":decrypting_random_access_stream",
        "//:crypto_format",
        "//:input_stream",
        "//:output_stream",
        "//:primitive_set",
        "//:primitive_wrapper",
        "//:random_access_stream",
        "//:registry",
        "//:streaming_aead",
        "//proto:tink_cc_proto",
        "//util:status",
        "//util:statusor",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "streaming_aead_config",
    srcs = ["streaming_aead_config.cc"],
    hdrs = ["streaming_aead_config.h"],
    include_prefix = "tink/streamingaead",
    visibility = ["//visibility:public"],
    deps = [
        ":aes_ctr_hmac_streaming_key_manager",
        ":aes_gcm_hkdf_streaming_key_manager",
        ":streaming_aead_wrapper",
        "//:registry",
        "//config:config_util",
        "//config:tink_fips",
        "//proto:config_cc_proto",
        "//util:status",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/memory",
    ],
)

cc_library(
    name = "streaming_aead_key_templates",
    srcs = ["streaming_aead_key_templates.cc"],
    hdrs = ["streaming_aead_key_templates.h"],
    include_prefix = "tink/streamingaead",
    visibility = ["//visibility:public"],
    deps = [
        "//proto:aes_ctr_hmac_streaming_cc_proto",
        "//proto:aes_gcm_hkdf_streaming_cc_proto",
        "//proto:common_cc_proto",
        "//proto:tink_cc_proto",
    ],
)

cc_library(
    name = "aes_gcm_hkdf_streaming_key_manager",
    srcs = ["aes_gcm_hkdf_streaming_key_manager.cc"],
    hdrs = ["aes_gcm_hkdf_streaming_key_manager.h"],
    include_prefix = "tink/streamingaead",
    deps = [
        "//:core/key_type_manager",
        "//:key_manager",
        "//:streaming_aead",
        "//proto:aes_gcm_hkdf_streaming_cc_proto",
        "//proto:tink_cc_proto",
        "//subtle:aes_gcm_hkdf_stream_segment_encrypter",
        "//subtle:aes_gcm_hkdf_streaming",
        "//subtle:random",
        "//util:constants",
        "//util:enums",
        "//util:errors",
        "//util:input_stream_util",
        "//util:protobuf_helper",
        "//util:secret_data",
        "//util:status",
        "//util:statusor",
        "//util:validation",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "aes_ctr_hmac_streaming_key_manager",
    srcs = ["aes_ctr_hmac_streaming_key_manager.cc"],
    hdrs = ["aes_ctr_hmac_streaming_key_manager.h"],
    include_prefix = "tink/streamingaead",
    deps = [
        "//:core/key_type_manager",
        "//:key_manager",
        "//:streaming_aead",
        "//proto:aes_ctr_hmac_streaming_cc_proto",
        "//proto:tink_cc_proto",
        "//subtle:aes_ctr_hmac_streaming",
        "//subtle:random",
        "//util:constants",
        "//util:enums",
        "//util:errors",
        "//util:input_stream_util",
        "//util:protobuf_helper",
        "//util:secret_data",
        "//util:status",
        "//util:statusor",
        "//util:validation",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "buffered_input_stream",
    srcs = ["buffered_input_stream.cc"],
    hdrs = ["buffered_input_stream.h"],
    include_prefix = "tink/streamingaead",
    deps = [
        "//:input_stream",
        "//util:errors",
        "//util:status",
        "//util:statusor",
        "@com_google_absl//absl/memory",
    ],
)

cc_library(
    name = "shared_input_stream",
    srcs = ["shared_input_stream.h"],
    hdrs = ["shared_input_stream.h"],
    include_prefix = "tink/streamingaead",
    deps = [
        "//:input_stream",
        "//util:errors",
        "//util:statusor",
        "@com_google_absl//absl/memory",
    ],
)

cc_library(
    name = "shared_random_access_stream",
    srcs = ["shared_random_access_stream.h"],
    hdrs = ["shared_random_access_stream.h"],
    include_prefix = "tink/streamingaead",
    deps = [
        "//:random_access_stream",
        "//util:buffer",
        "//util:status",
        "//util:statusor",
    ],
)

cc_library(
    name = "decrypting_input_stream",
    srcs = ["decrypting_input_stream.cc"],
    hdrs = ["decrypting_input_stream.h"],
    include_prefix = "tink/streamingaead",
    deps = [
        ":buffered_input_stream",
        ":shared_input_stream",
        "//:input_stream",
        "//:primitive_set",
        "//:streaming_aead",
        "//util:errors",
        "//util:status",
        "//util:statusor",
        "@com_google_absl//absl/memory",
    ],
)

cc_library(
    name = "decrypting_random_access_stream",
    srcs = ["decrypting_random_access_stream.cc"],
    hdrs = ["decrypting_random_access_stream.h"],
    include_prefix = "tink/streamingaead",
    deps = [
        ":shared_random_access_stream",
        "//:primitive_set",
        "//:random_access_stream",
        "//:streaming_aead",
        "//util:buffer",
        "//util:errors",
        "//util:status",
        "//util:statusor",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/synchronization",
    ],
)

# tests

cc_test(
    name = "streaming_aead_wrapper_test",
    size = "small",
    srcs = ["streaming_aead_wrapper_test.cc"],
    copts = ["-Iexternal/gtest/include"],
    deps = [
        ":streaming_aead_wrapper",
        "//:input_stream",
        "//:output_stream",
        "//:primitive_set",
        "//:random_access_stream",
        "//:streaming_aead",
        "//proto:tink_cc_proto",
        "//subtle:random",
        "//subtle:test_util",
        "//util:buffer",
        "//util:file_random_access_stream",
        "//util:istream_input_stream",
        "//util:ostream_output_stream",
        "//util:status",
        "//util:test_matchers",
        "//util:test_util",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_test(
    name = "aes_gcm_hkdf_streaming_key_manager_test",
    size = "small",
    srcs = ["aes_gcm_hkdf_streaming_key_manager_test.cc"],
    deps = [
        ":aes_gcm_hkdf_streaming_key_manager",
        "//:streaming_aead",
        "//proto:aes_eax_cc_proto",
        "//proto:aes_gcm_hkdf_streaming_cc_proto",
        "//proto:common_cc_proto",
        "//proto:tink_cc_proto",
        "//subtle:aes_gcm_hkdf_streaming",
        "//subtle:common_enums",
        "//subtle:random",
        "//subtle:streaming_aead_test_util",
        "//subtle:test_util",
        "//util:istream_input_stream",
        "//util:ostream_output_stream",
        "//util:secret_data",
        "//util:status",
        "//util:statusor",
        "//util:test_matchers",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_test(
    name = "aes_ctr_hmac_streaming_key_manager_test",
    size = "small",
    srcs = ["aes_ctr_hmac_streaming_key_manager_test.cc"],
    deps = [
        ":aes_ctr_hmac_streaming_key_manager",
        "//:streaming_aead",
        "//proto:aes_ctr_hmac_streaming_cc_proto",
        "//proto:aes_eax_cc_proto",
        "//proto:common_cc_proto",
        "//proto:tink_cc_proto",
        "//subtle:aes_ctr_hmac_streaming",
        "//subtle:common_enums",
        "//subtle:random",
        "//subtle:streaming_aead_test_util",
        "//subtle:test_util",
        "//util:istream_input_stream",
        "//util:ostream_output_stream",
        "//util:secret_data",
        "//util:status",
        "//util:statusor",
        "//util:test_matchers",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_test(
    name = "streaming_aead_key_templates_test",
    size = "small",
    srcs = ["streaming_aead_key_templates_test.cc"],
    deps = [
        ":aes_ctr_hmac_streaming_key_manager",
        ":aes_gcm_hkdf_streaming_key_manager",
        ":streaming_aead_key_templates",
        "//proto:aes_ctr_hmac_streaming_cc_proto",
        "//proto:aes_gcm_hkdf_streaming_cc_proto",
        "//proto:common_cc_proto",
        "//proto:tink_cc_proto",
        "//util:test_matchers",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_test(
    name = "streaming_aead_config_test",
    size = "small",
    srcs = ["streaming_aead_config_test.cc"],
    tags = [
        "fips",
    ],
    deps = [
        ":aes_ctr_hmac_streaming_key_manager",
        ":aes_gcm_hkdf_streaming_key_manager",
        ":streaming_aead_config",
        ":streaming_aead_key_templates",
        "//:config",
        "//:keyset_handle",
        "//:registry",
        "//:streaming_aead",
        "//config:tink_fips",
        "//util:status",
        "//util:test_matchers",
        "//util:test_util",
        "@com_google_absl//absl/memory",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_test(
    name = "buffered_input_stream_test",
    size = "small",
    srcs = ["buffered_input_stream_test.cc"],
    linkopts = ["-lpthread"],
    deps = [
        ":buffered_input_stream",
        "//:input_stream",
        "//subtle:random",
        "//subtle:test_util",
        "//util:istream_input_stream",
        "//util:status",
        "//util:test_matchers",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_test(
    name = "decrypting_input_stream_test",
    size = "small",
    srcs = ["decrypting_input_stream_test.cc"],
    deps = [
        ":decrypting_input_stream",
        "//:input_stream",
        "//:output_stream",
        "//:primitive_set",
        "//:streaming_aead",
        "//proto:tink_cc_proto",
        "//subtle:random",
        "//subtle:test_util",
        "//util:istream_input_stream",
        "//util:ostream_output_stream",
        "//util:status",
        "//util:test_matchers",
        "//util:test_util",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_test(
    name = "decrypting_random_access_stream_test",
    size = "small",
    srcs = ["decrypting_random_access_stream_test.cc"],
    deps = [
        ":decrypting_random_access_stream",
        "//:output_stream",
        "//:primitive_set",
        "//:random_access_stream",
        "//:streaming_aead",
        "//proto:tink_cc_proto",
        "//subtle:random",
        "//subtle:test_util",
        "//util:file_random_access_stream",
        "//util:ostream_output_stream",
        "//util:status",
        "//util:test_matchers",
        "//util:test_util",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_test(
    name = "shared_input_stream_test",
    size = "small",
    srcs = ["shared_input_stream_test.cc"],
    linkopts = ["-lpthread"],
    deps = [
        ":buffered_input_stream",
        ":shared_input_stream",
        "//:input_stream",
        "//subtle:random",
        "//subtle:test_util",
        "//util:istream_input_stream",
        "//util:status",
        "//util:test_matchers",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_test(
    name = "shared_random_access_stream_test",
    size = "small",
    srcs = ["shared_random_access_stream_test.cc"],
    linkopts = ["-lpthread"],
    deps = [
        ":shared_random_access_stream",
        "//:random_access_stream",
        "//util:buffer",
        "//util:file_random_access_stream",
        "//util:status",
        "//util:test_util",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest_main",
    ],
)
